package com.atwisdom.star.core.dao.service.modelClass.tank.Impl;

import com.atwisdom.star.core.dao.mapper.modelClass.TankInstanceMapper;
import com.atwisdom.star.core.dao.pojo.modelClass.tank.TankInstance;
import com.atwisdom.star.core.dao.service.modelClass.tank.TankInstanceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
* @author fushb
* @description 针对表【tank_instance】的数据库操作Service实现
* @createDate 2023-03-30 14:27:39
*/
@Service
public class TankInstanceServiceImpl extends ServiceImpl<TankInstanceMapper, TankInstance>
    implements TankInstanceService {
    @Override
    public int realDelete(QueryWrapper<TankInstance> wrapper){
        return this.baseMapper.realDelete(wrapper);
    }

    /**
     * 同步更新实例类名称
     * @param type 原类名
     * @param className 原类名
     * @param oldType 原类名
     * @param oldClassName 新类名
     * @return 返回结果
     */
    @Override
    public int updateClassName(String type,String className,String oldType,String oldClassName ) {
        QueryWrapper<TankInstance> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("className", oldClassName);
        queryWrapper.eq("type", oldType);
        queryWrapper.eq("published", true);
        TankInstance instance = new TankInstance();
        instance.setClassName(className);
        instance.setType(type);
        return this.baseMapper.update(instance, queryWrapper);
    }
}




